<template>
  <div class="collect-page">
    <van-nav-bar title="我的收藏" fixed />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <ArticleItem
        v-for="item in list"
        :key="item.id"
        :item="item"
      ></ArticleItem>
    </van-list>
  </div>
</template>

<script>
import { collectListApi } from '@/api/article'
export default {
  name: 'CollectPage',
  data () {
    return {
      loading: false,
      finished: false,
      page: 1,
      pageSize: 10,
      list: []
    }
  },
  methods: {
    async onLoad () {
      const { data } = await collectListApi(this.page, this.pageSize)
      this.list.push(...data.rows)
      // 表示可以请求下一页
      this.loading = false
      this.page++
      if (this.page > data.pageTotal) {
        this.finished = true
      }
    }
  }
}
</script>

<style lang="less" scoped>
.collect-page {
  margin-bottom: 50px;
  margin-top: 44px;
}
</style>
